package com.onpositive.wiki2.whole.model;

import java.io.File;
import java.io.IOException;

import com.onpositive.wiki2.miner.AbstractWikiPediaVisitor;
import com.onpositive.wiki2.miner.CompositeVisitor;
import com.onpositive.wiki2.miner.Page;
import com.onpositive.wiki2.miner.WikiPediaPass;

public class ContentChecker {

	public static void main(String[] args) {
		File file = new File(Constants.PATH);
		try {
			final ContentAccess c = new ContentAccess(file.getAbsolutePath());
			CompositeVisitor va = new CompositeVisitor();
			va.add(new AbstractWikiPediaVisitor() {

				int a = 0;

				@Override
				protected void onPage(Page page) {
					String content;
					try {
						content = c.getContent(a);
						String mn=c.getContent(page.title);
						String title = c.getTitle(a);
						if (!title.equals(page.title)){
							System.out.println("error");
						}
						if (!content.equals(page.textContent)||!content.equals(mn)) {
							System.out.println(content);
						}
						a++;
						if (a % 1000 == 0) {
							System.out.println(a);
						}
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}

				}
			});
			WikiPediaPass.doPass(va);
		} catch (Exception e) {
			e.printStackTrace();
			// TODO: handle exception
		}
	}
}
